<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" name=""id="a1">
    <script>
        let a = document.getElementById("a1")
        a.addEventListener("keydown",function(event){
            console.log(event)
            console.log(event.code)//更详细能区分不同地方的键
            console.log(event.key)
        })
        //event  是事件的对象 代表事件的状态
    </script>
</body>
</html>